package com.zhuhjay.statistics.schedule;

import com.zhuhjay.statistics.service.StatisticsDailyService;
import com.zhuhjay.statistics.utils.DateUtil;
import org.apache.http.client.utils.DateUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author ZhuHJay
 * @date 2022/9/10 11:30
 */
@Component
public class ScheduleTask {

    @Resource
    private StatisticsDailyService dailyService;

    @Scheduled(cron = "0 0 1 * * ?")
    public void task() {
        // 更新前一天的数据
        dailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }

}
